import svmMLiA
from numpy import *
#优化前
dataArr ,labelArr = svmMLiA.loadDataSet('testSet.txt')
#b,alphas = svmMLiA.smoSimple(dataArr,labelArr,0.6,0.001,40)
#print("b:\n",b)
#求出的alpha值就是!=0的那些就是对应的支持向量
#print("alphas:\n",alphas[alphas>0])

#mySum = mat([-1,-3,1,3,4,5,6,1])
#print("mySum:\n",mySum[mySum>0])

#优化后 
b , alphas = svmMLiA.smoP(dataArr,labelArr,0.6,0.001,40)
#计算WS
ws = svmMLiA.calcWs(alphas,dataArr,labelArr)
print("ws:\n",ws)
dataMat = mat(dataArr)
print("dataMat:\n",dataMat)
#代入第一个数据 y = wx +b
print("dataMat[0]*mat(ws) +b :\n",dataMat[0]*mat(ws) +b)

#使用了核函数
svmMLiA.testRbf()